package org.dwpd.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSenderImpl;

/**
 * Package:org.dwpd.config
 *
 * @ClassName:EmailConfig
 * @Create:2024/5/14 16:54
 **/
@Configuration
public class EmailConfig {
    @Value("${spring.mail.username}")
    private String username;
    @Value("${spring.mail.password}")
    private String password;
    @Value("${spring.mail.host}")
    private String host;
    @Value("${spring.mail.defaultEncoding}")
    private String defaultEncoding;
    @Value("${spring.mail.port}")
    private int port;
    @Value("${spring.mail.protocol}")
    private String protocol;


    public EmailConfig() {
    }
    @Bean
    public JavaMailSenderImpl javaMailSender(){
        JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
        javaMailSender.setUsername(username);
        javaMailSender.setPassword(password);
        javaMailSender.setHost(host);
        javaMailSender.setDefaultEncoding(defaultEncoding);
        javaMailSender.setPort(port);
        javaMailSender.setProtocol(protocol);
        return javaMailSender;
    }
}
